<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" import="com.xiaoquan.model.Resc" contentType="text/html; charset=UTF-8" %>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>菜单维护</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="/bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="/dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="/dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="/plugins/iCheck/flat/blue.css">
    <!-- Morris chart -->
    <link rel="stylesheet" href="/plugins/morris/morris.css">
    <!-- jvectormap -->
    <link rel="stylesheet" href="/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="/plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="/plugins/daterangepicker/daterangepicker-bs3.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="/js/html5shiv.min.js"></script>
    <script src="/js/respond.min.js"></script>
    <![endif]-->

<body class="skin-blue sidebar-mini wysihtml5-supported">
<jsp:include page="header.jsp"/>
<jsp:include page="menu.jsp"/>



<script language="javascript">
        function check(form) {
            var name = $("#name").val();
            var url = $("#url").val();
            var level = $("#level").val();
            var priority = $("#priority").val();

            if (name == "" || name == null) {
                alert("菜单名称不能为空!");
                return false;
            }

            if (url == "" || url == null) {
                            alert("url不能为空!");
                            return false;
                        }

            if (level == "" || level == null) {
                alert("等级不能为空!");
                return false;
            }

            if (priority == "" || priority == null) {
                 alert("权限不能为空!");
                 return false;
             }
        }
    </script>


<div class="content-wrapper">
    <section class="content-header">
        <c:if test="${resc == null}">
            <h1>
                添加菜单
            </h1>
            <ol class="breadcrumb">
                <li><a href="${firstMenuUrl}"><i class="fa fa-dashboard"></i>${firstMenuName}</a></li>
                <li><a href="${secMenuUrl}"><i class="fa fa-dashboard"></i>${secMenuName}</a></li>
                <li class="active">添加菜单</li>
            </ol>
        </c:if>
        <c:if test="${resc != null}">
            <h1>
                修改菜单
            </h1>
            <ol class="breadcrumb">
                <li><a href="${firstMenuUrl}"><i class="fa fa-dashboard"></i>${firstMenuName}</a></li>
                <li><a href="${secMenuUrl}"><i class="fa fa-dashboard"></i>${secMenuName}</a></li>
                <li class="active">修改菜单</li>
            </ol>
        </c:if>
    </section>

    <section class="content">
        <div class="box box-info">
            <div class="box-header with-border">
            </div>

            <c:if test="${resc == null}">
            <form class="form-horizontal" action="${pageContext.request.contextPath}/menuAdd" method="post" onsubmit="javascript:return check();">
                </c:if>
                <c:if test="${resc != null}">
                <form class="form-horizontal" action="${pageContext.request.contextPath}/menuEdit" method="post" onsubmit="javascript:return check();">
                    </c:if>
                    <input type="hidden" name="id" value="${resc.id}"/>

                    <div class="box-body">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">URL</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="url" placeholder="URL" name="resString"
                                       value="${resc.resString}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">菜单名</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="name" placeholder="name"
                                       name="name" value="${resc.name}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">等级</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="level" placeholder="level"
                                       name="level" value="${resc.level}">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">权限</label>

                            <div class="col-sm-10">
                                <input type="text" class="form-control" id="priority" placeholder="priority"
                                       name="priority" value="${resc.priority}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">上级菜单</label>

                            <div class="col-sm-10">
                                <select id="parentId" name="parentId"
                                        class="form-control select2 select2-hidden-accessible" style="width: 100%;"
                                        tabindex="-1" aria-hidden="true">
                                    <c:forEach var="item" items="${parentIdList}" varStatus="status">
                                        <option value="${item.id}">${item.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                        </div>


                    </div>

                    <div class="box-footer">
                        <button type="submit" class="btn btn-info pull-right">提交</button>
                    </div>
                </form>
        </div>

    </section>
</div>


</div>

<!-- jQuery 2.1.4 -->
<script src="/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="/js/jquery-ui.min.js"></script>
<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
<script>
    $.widget.bridge('uibutton', $.ui.button);
</script>
<!-- Bootstrap 3.3.5 -->
<script src="/bootstrap/js/bootstrap.min.js"></script>
<!-- Sparkline -->
<script src="/plugins/sparkline/jquery.sparkline.min.js"></script>
<!-- jvectormap -->
<script src="/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- jQuery Knob Chart -->
<script src="/plugins/knob/jquery.knob.js"></script>
<!-- daterangepicker -->
<script src="/js/moment.min.js"></script>
<script src="/plugins/daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="/plugins/datepicker/bootstrap-datepicker.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<script src="/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/plugins/fastclick/fastclick.min.js"></script>
<!-- AdminLTE App -->
<script src="/dist/js/app.min.js"></script>
<c:if test="${resc != null && resc.parentId != null}">
    <script>
        $('#parentId option[value="' + <%=((Resc)request.getAttribute("resc")).getParentId()%> +'"]').attr('selected', "selected");
    </script>
</c:if>
</body>
</html>